<script setup lang="ts">
import { onMounted, ref } from 'vue';
var props = defineProps<{
    xml?: string, /** 地址 */
    name?: string
}>();
const path = ref()

interface Cdrom {
    path: string
    type: string
}

const change = ()=>{
    console.log(disk.value.path)
}
const cdromParse = ()=>{
    /**参数解析*/
    if(props.name != null){
        return props.name
    }else if(props.xml != null){
        const parser = new DOMParser();
        const doc = parser.parseFromString(props.xml, "text/xml");
        path.value = doc.getElementsByTagName("source")[0]?.getAttribute("file")
    }
}

const disk = ref<Cdrom>({path: "", type: "STAT"})
const ioTypes = ["STAT","SCSI" ,"USB"]
onMounted(()=>{
    cdromParse()
})
</script>

<template>
    <el-form-item label="光盘">
        <el-input v-model="disk.path" @input="change" style="width: 75%"/>
        <label style="margin: 0px 7px">io类型</label>
        <el-select v-model="disk.type" style="width: 15%">
            <template v-for="arch in ioTypes">
                <el-option :label="arch" :value="arch" />
            </template>
        </el-select>
    </el-form-item>
</template>